<template>
	<view>
		<u-navbar :is-back="false"  :border-bottom="false"></u-navbar>
		<view class="topImg">废旧金属回收登记系统</view>
		<view class="allType">
			<view class="addData" @tap="clickAdd">
				<image src="../../static/addData.png" style="width: 20%;" mode="aspectFit"></image>
				<view class="title">新增数据</view>
			</view>
			<!-- <view class="dataList" @tap="clickInfo">
				<image src="../../static/people.png" style="width: 20%;" mode="aspectFit"></image>
				<view class="title">客户信息</view>
			</view> -->
			<view class="dataList" @tap="clickRecord">
				<image src="../../static/dataList.png" style="width: 20%;" mode="aspectFit"></image>
				<view class="title">数据记录</view>
			</view>
		</view>
		<view class="allType" style="margin-top: 40rpx;">
			<view @tap="loginOut" style="width: 140rpx;height: 70rpx;background-color: #9CC9DE;line-height: 70rpx;border-radius: 5rpx;text-align: center;color: #fff;margin-left: 15rpx;">
				退出登录
			</view>
			<view @tap="addPeople" style="width: 140rpx;height: 70rpx;background-color: #9CC9DE;line-height: 70rpx;border-radius: 5rpx;text-align: center;color: #fff;margin-right: 15rpx;">
				添加从业人员
			</view>
		</view>
		
		<!-- <view class="allType1" @tap="clickRecord">
			<view class="dataList">
				<image src="../../static/dataList.png" style="width: 20%;" mode="aspectFit"></image>
				<view class="title">数据记录</view>
			</view>
		</view> -->
		<view class="bottomImg"></view>
	</view>
</template>

<script>
	import config from '@/utils/config.js';
	export default {
		data(){
			return {
				
			}
		},
		onShow(){
			console.log(uni.getStorageSync('token'),"token");
			this.getToken();
		},
		methods:{
			// clickInfo(){   //点击客户信息
			// 	uni.navigateTo({
			// 		url:"../info/index"
			// 	})
			// },
			getToken(){
				uni.request({
					url: config.host + '/huishou/pcLogin/getAppLoginInfo', //接口地址。
					data: {
						token: uni.getStorageSync('token')
					},
					method: 'POST',
					header: {
						'content-type': 'application/json;charset=UTF-8'
					},
					success: (res) => {
						if(Object.keys(res.data.item).length == 0){
							uni.showToast({
								icon: 'none',
								title: '身份已过期，请重新登录！'
							});
							setTimeout(() => {
								uni.navigateTo({
									url: '../login/index'
								})
							}, 800);
							
						}else{
							
						}
					},
					fail: (err) => {
						uni.showToast({
							icon: 'none',
							title: '网络异常,请稍后重试'
						});
					}
				});
			},
			clickRecord(){   //点击数据记录
				uni.navigateTo({
					url:"../record/index"
				})
			},
			clickAdd(){   //点击新增数据
				uni.navigateTo({
					url:"../addData/index"
				})
			},
			loginOut(){
				uni.clearStorageSync();
				setTimeout(() => {
					uni.navigateTo({
						url: '../login/index'
					})
				}, 300);
			},
			addPeople(){
				uni.navigateTo({
					url: '../addPeople/index'
				})
			},
		}
	}
</script>

<style lang="scss">
	@import url("./css/index.css");
</style>

			